function ProductInfo_Code() {
	var buffer = new StringBuffer();
	buffer.append('<div class="orderinfo"><div class="line100"><font class="blacks">产品编号：</font><font id="num">加载中...</font></div><div class="line100"><font class="blacks">产品名称：</font><font id="name"></font></div><div class="line100"><font class="blacks">产品图片：</font><font id="img"></font></div><div class="line100"><font class="blacks">成&nbsp; 本 &nbsp;价：</font><font id="costprice"></font></div><div class="line100"><font class="blacks">产品售价：</font><font id="price"></font></div><div class="line100"><font class="blacks">产品单位：</font><font id="unit"></font></div><div id="expand_tags"></div><div class="line100"><font class="blacks">最后修改时间：</font><font id="lasteditdate"></font></div><div class="line100"><font class="blacks">产品创建时间：</font><font id="createdate"></font></div><div class="line100"><font class="blacks">备注：</font><font id="bak"></font></div></div>');
	return buffer.toString();
};


function Init_ProductDetail(){
	
	var data = {};
    data.act = "One_Product";
    data.id = obj.attr("id");
    data.userid=userid;
	data.comid=comid;
	data.source=source;
	data.pagesize=PAGE_SIZE10;
	data.sign=GetSign(data.act);
    mui.getJSON(crm_domain, data, function(json) {
    	var product = json.data.product;
    	var str="";
        var tags = json.data.tags;
        $("#num").html(product.Num);
        $("#name").html(product.Name);
        $("#img").html(product.Img==""?"暂无":"<img src='"+ domain +product.Img +"' width='50%' style='vertical-align:top' />");
        $("#costprice").html(product.CostPrice.toFixed(2));
        $("#price").html(product.Price.toFixed(2));
        $("#unit").html(product.Unit);
        $("#bak").html(product.Bak.ToString());
        $("#lasteditdate").html(product.LastEditDate);
        $("#createdate").html(product.CreateDate);
        //初始化拓展字段
        Init_ProductExpandTags(tags);
    });
};

//初始化拓展字段
function Init_ProductExpandTags(tags) {
    var str="";
    $.each(tags,function(i,info){
        str+='<div class="line100">'+info.Name+'：<font>'+info.Value+'</font></div>';
    });
    $("#expand_tags").html(str);
};

function ProductTool()
{
	if($("#producttool").length>0)
	{
		$("#producttool").show();
	}else
	{
		$("body").append('<div id="producttool" class="customertool" style="height:120px;"><ul><li id="productedit">修改产品</li><li id="productdelete">删除产品</li></ul></div>');
		//初始化工具条
		
        
		get("productedit").addEventListener("tap",function(){
        	OpenWindow(3,"产品","保存",function(){
				Save_Product();
			});
			$("#contentlist3").html(ProductAdd_Code(obj.attr("id")));
			Init_ProductAdd();
			$("#producttool").hide();
        });
        
        get("productdelete").addEventListener("tap",function(){
        	$("#producttool").hide(); 
        	plus.nativeUI.confirm("确定要删除吗？", function(event){
				if(event.index==1)
				{
					var data = {};
				    data.act = "Delete_Product";
				    data.ids = obj.attr("id");
				    data.userid=userid;
					data.comid=comid;
					data.source=source;
					data.sign=GetSign(data.act);
				    mui.getJSON(crm_domain, data, function(json) {
				    	plus.nativeUI.toast(json.msg);
						if(json.state)
						{
							CloseWindow();
							obj.remove();
						}
				    });	
				}
			},"提示", ["取消","确认"]); 
        });
	}
};
